package com.ruoyi.web.controller.tool;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JzToursShop;
import com.ruoyi.system.service.IJzToursShopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商家信息Controller
 * 
 * @author ruoyi
 * @date 2021-03-18
 */
@RestController
@RequestMapping("/system/shop")
@Api("商家信息")
public class JzToursShopController extends BaseController
{
    @Autowired
    private IJzToursShopService jzToursShopService;

    /**
     * 查询商家信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(JzToursShop jzToursShop)
    {
        startPage();
        List<JzToursShop> list = jzToursShopService.selectJzToursShopList(jzToursShop);
        return getDataTable(list);
    }

    /**
     * 导出商家信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:export')")
    @Log(title = "商家信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JzToursShop jzToursShop)
    {
        List<JzToursShop> list = jzToursShopService.selectJzToursShopList(jzToursShop);
        ExcelUtil<JzToursShop> util = new ExcelUtil<JzToursShop>(JzToursShop.class);
        return util.exportExcel(list, "shop");
    }

    /**
     * 获取商家信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jzToursShopService.selectJzToursShopById(id));
    }

    /**
     * 新增商家信息
     */
   @PreAuthorize("@ss.hasPermi('system:shop:add')")
    @Log(title = "商家信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增商家信息")
    public AjaxResult add(@RequestBody JzToursShop jzToursShop)
    {
        return toAjax(jzToursShopService.insertJzToursShop(jzToursShop));
    }

    /**
     * 修改商家信息
     */
    @PreAuthorize("@ss.hasPermi('system:shop:edit')")
    @Log(title = "商家信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改商家信息")
    public AjaxResult edit(@RequestBody JzToursShop jzToursShop)
    {
        return toAjax(jzToursShopService.updateJzToursShop(jzToursShop));
    }

    /**
     * 删除商家信息
     */
    @PreAuthorize("@ss.hasPermi('system:shop:remove')")
    @Log(title = "商家信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除商家信息")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return toAjax(jzToursShopService.deleteJzToursShopById(ids));
    }


    /**
     * 获取文章详情所有可添加的行程列表
     *
     */
    @GetMapping("/getAllList")
    @ApiOperation("获取行程里面所有信息")
    public AjaxResult getAllList(){


        return AjaxResult.success(jzToursShopService.getAllList()) ;
    }


}
